package com.hospital.hospitalserver.controller;

import com.hospital.hospitalserver.entity.NurseDetail;
import com.hospital.hospitalserver.service.NurseService;
import com.hospital.hospitalserver.service.ProfessionService;
import com.hospital.hospitalserver.util.Pager;
import com.hospital.hospitalserver.util.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 护士相关功能API接口
 * */
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/nurse")
public class NurseController {
    private final NurseService nurseService;
    private final ProfessionService professionService;

    /**
     * 新增护士
     * 添加事务处理，执行有错误回滚操作
     * */
    @PostMapping("/addNurse")
    public Response addNurse(@RequestBody NurseDetail nurse){
        return nurseService.addNurse(nurse);
    }

    /**
     * 编辑护士信息
     * */
    @PostMapping("/editNurse")
    public Response editNurse(@RequestBody NurseDetail nurse){
        return nurseService.editNurse(nurse);
    }

    /**
     * 获取护士职称信息列表
     * */
    @GetMapping("/getNurseProfessionList")
    public Response getNurseProfessionList(){
        return professionService.getNurseProfessionList();
    }

    /**
     * 分页功能
     * 装载护士分页数据信息给前端API
     * */
    @PostMapping("/getNursePagerDataBySearch")
    public Response getNursePagerDataBySearch(@RequestBody Pager pager){
        return nurseService.getNursePagerDataBySearch(pager);
    }

    /**
     * 获取护士的列表数据
     * 用于查询检索
     * */
    @GetMapping("/getNurseList")
    public Response getNurseList(){
        return nurseService.getNurseList();
    }
}
